<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.ProblemBrowseCondition"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.shsh.safemanage.dao.EquipmentDao"%>
<%@page import="com.shsh.safemanage.model.Equipment"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.model.Department1"%>

<%
DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();

String theFromPage = request.getParameter(Constants.REQUEST_PARAMETER_FROM_PAGE);
if (theFromPage == null || !theFromPage.equals("deleted")) {
	session.removeAttribute(Constants.SESSION_PROBLEM_CONDITION);
}
%>
<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="../images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台&gt;&gt; 系统管理
	&gt;&gt; 问题管理
</div>
<div class="tt">问题管理</div>
<div class="content">
	<div class="apptab">
		<table width="100%" border="0" cellpadding="0" cellspacing="0"
			style="font-size: 12px; color: #000; line-height: 25px;">
			<tr>
				<td width="13" class="appbg">&nbsp;</td>
				<td width="97" class="appbg"><img src="../images/trace.gif"
					style="vertical-align: middle;" />查询条件</td>
				<td width="554" class="appbg">&nbsp;</td>
				<td colspan="2" class="appbg">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3">
					<span style="margin-left: 30px">作业部：</span>
					<span> 
					<%@include file="depart_select/depart1_shiyebu_select_section.jsp"%>
					</span> 
					<span style="margin-left: 10px">装置：</span> 
					<span id="equipOfDepartSpan">
						<%@include file="equip_select/equipment_of_depart_select_section.jsp"%>
					</span>
					 
					<br />
					
					<span style="margin-left: 30px">问题标题： </span><input type="text" size="15" id="problemTitle" />
					<span style="margin-left: 10px">全文： </span><input type="text" size="25" id="problemContent" />
					<font color="#666666">（可模糊查询相关文字）</font>
					
					<br />
					
					<span style="margin-left: 30px">填报日期区间：</span> <input type="text" id="dateStart"
					size="15"
					onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'dateStart\')||\'2050-12-31\'}'})" />-<input
					type="text" id="dateEnd" size="15"
					onfocus="WdatePicker({minDate:'#F{$dp.$D(\'dateEnd\')}',maxDate:'2050-12-31'})" />
				</td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3" style="text-align: center;"><a
					href="javascript:" onclick="browseProblems(1)"><img
						src="../images/cha.gif" /></a></td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="5">
				<span id="monthSpan">
					<%@include file="month_href_section.jsp" %>
				</span>
				</td>
			</tr>
			<tr>
				<td colspan="5" height="20">&nbsp;</td>
			</tr>
		</table>
	</div>
	<div class="apptab" id="problemBrowseListTD">
		<%@include file="problem_list.jsp"%>
	</div>
</div>

<script type="text/javascript">
	function deleteProblem(){
		var problemIDs = '';
		$("input[@name='problemChecker']").each(function() {
			if($(this).attr("checked")){
				problemIDs = problemIDs + ',' + $(this).val();
			} 
		});
		
		if(problemIDs == ''){
			$.dialog.alert('请先选择需要删除的问题');
			return;
		}
		
		problemIDs = problemIDs.substring(1, problemIDs.length);
		$.dialog.confirm('该问题删除后无法恢复，请谨慎删除，您是否确认删除？', function(){
			openWaitingDialog('waitingDialog');
			$.ajax({
				type:'post',
				url:'delete_problem_process.jsp',
				data:{			
					problemIDs: problemIDs
				},
				success:function(data,state,xmlhttp){
					var obj = null;
					try {
						obj = eval('(' + data + ')');
					} catch (e) {
					}
					if (typeof(obj.isSuccess) != 'undefined') {
						closeWaitingDialog('waitingDialog');
						if (obj.isSuccess == 'true') {					
							$.dialog('删除成功！', function() { 
								loadPageSection('<%=request.getContextPath()%>/admin/problem_browse.jsp', 'mainContentDiv',
										{
											fromPage: 'deleted'
										}, 
										true); });					
						} else {
							$.dialog.alert(obj.error);
						}
					}
				}
			});
		});
	}

	function browseProblems(pageNum) {
		openWaitingDialog('waitingDialog');
		loadPageSection('<%=request.getContextPath()%>/admin/problem_search_list.jsp', 'problemBrowseListTD',
				{
					departmentID : getElementValueByID('depart1'),
					equipID : getElementValueByID('equipID'),
					problemTitle : getElementValueByID('problemTitle'),
					problemContent : getElementValueByID('problemContent'),
					dateStart : getElementValueByID('dateStart'),
					dateEnd : getElementValueByID('dateEnd'),
					pageNum: pageNum
				});
	}

	function browseAllProblemByMonth(dateStart, dateEnd) {
		loadPageSection('<%=request.getContextPath()%>/admin/problem_search_list.jsp', 'problemBrowseListTD',
		{
			dateStart : dateStart,
			dateEnd : dateEnd
		}, true);
	}
	function browseOverallProblems(pageNum) {
		loadPageSection('<%=request.getContextPath()%>/admin/problem_list.jsp', 'problemBrowseListTD', 
		{
			pageNum: pageNum
		}, 
		true
		);
	}
	function selectDepart1() {
		loadPageSection(
				'<%=request.getContextPath()%>/admin/equip_select/equipment_of_depart_select_section.jsp',
				'equipOfDepartSpan', {
					depart1ID : getElementValueByID('depart1')
				}, false, function() {
					document.getElementById('equipID').value = '';
				});
	}

	selectDepart1();
</script>
